package com.auxgroup.hr.front.service.hireperson.impl;

import java.sql.Timestamp;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import com.auxgroup.hr.front.commons.utils.ObjectFieldUtils;
import com.auxgroup.hr.front.dao.domain.PsCHireBankacct;
import com.auxgroup.hr.front.dao.repository.PsCHireBankacctRepository;
import com.auxgroup.hr.front.service.hireperson.HireBankacctService;

/** 
 * @author lvliuhao
 * @version 创建时间：180523 
 * 入职人员银行账号service
 */
@Service("hireBankacctService")
public class HireBankacctServiceImpl implements HireBankacctService {
	private static final Logger logger = LoggerFactory.getLogger(HireEducatServiceImpl.class);
	
	@Autowired
	private PsCHireBankacctRepository PsCHireBankacctRepository;


	@Override
	public PsCHireBankacct getHireBankacct(String rsHireId) {
		return PsCHireBankacctRepository.findOne(rsHireId);
	}


	@Override
	public PsCHireBankacct save(PsCHireBankacct HireBankacct) {
		HireBankacct.setCountryCd("CHN");
		HireBankacct.setHrsRowUpdDttm(new Timestamp(System.currentTimeMillis()));
		HireBankacct.setHrsRowUpdOprid(HireBankacct.getRsHireId());
		ObjectFieldUtils.handleNullValue(HireBankacct);
		return PsCHireBankacctRepository.save(HireBankacct);
	}


	@Override
	public Boolean delete(String rsHireId) {
		try {
			PsCHireBankacctRepository.delete(rsHireId);
		} catch (Exception e) {
			logger.error("delete HireBankacct error: rsHireId={}",rsHireId,e);
			return false;
		}
		return true;
	}
	
	
	@Override
	public List<PsCHireBankacct> getAll(String rsHireId) {
		PsCHireBankacct HireBankacct = new PsCHireBankacct();
		HireBankacct.setRsHireId(rsHireId);
		return PsCHireBankacctRepository.findAll(Example.of(HireBankacct));
	}


	
	
	
}
